package com.flower.subject.application.controller;

import com.flower.subject.api.mqtt.MQTTConnect;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-09-23 16:03
 */
@RestController
@RequestMapping("/mqtt")
public class MQTTController {

    @Autowired
    private MQTTConnect mqttConnect;


    @GetMapping("pub")
    private String pub(){
        try {
            mqttConnect.pub("/mqtt/pub", "测试请求",0);
        } catch (MqttException e) {
            throw new RuntimeException(e);
        }

    return "成功";
    }

}
